Skip to content

Migrate scheduled-tasks delete from survey to huh#116

Open
blsmth wants to merge 4 commits intomainfrom
survey-to-huh-v2
Open

Migrate scheduled-tasks delete from survey to huh#116
blsmth wants to merge 4 commits intomainfrom
survey-to-huh-v2

Conversation

@blsmth
Copy link
Contributor

@blsmth blsmth commented Mar 19, 2026

Summary

  • Migrate scheduled-tasks delete interactive prompt from AlecAivazis/survey/v2 to charmbracelet/huh
  • Extract ScheduledTaskDeleteForm as a pure form builder function, decoupled from AWS
  • Add teatest-based TUI tests with simulated keypresses
  • Add testscript integration tests for scheduled-tasks CLI commands
  • Include VHS recording for visual verification

Demo

scheduled-tasks delete with huh

Recorded with VHS:

brew install vhs
vhs demo-scheduled-tasks-delete.tape

Changes

File Purpose
cmd/scheduledTasks.go Migrated from survey to huh; extracted ScheduledTaskDeleteForm builder
ui/questions.go New huh helpers (YesNoOptions, YesNoToBool, PrintQuestionHeader) alongside existing survey code
ui/uitest/helpers.go Reusable teatest helpers (RunForm, SelectNth, TypeAndSubmit, WaitDone)
integration_test.go testscript runner for .txtar CLI tests
testdata/script/*.txtar Integration tests for version, help, scheduled-tasks
demo-scheduled-tasks-delete.tape VHS script for recording the demo GIF

Approach

The previous attempt (PR #96) tried an all-at-once migration and caused issues. This PR establishes an incremental pattern:

  1. Extract form builders — pure functions that take data and return (*huh.Form, result pointers), independently testable without AWS mocks
  2. Two test layerstestscript for non-interactive CLI behavior, teatest for real TUI interaction
  3. VHS recordings — visual verification of each migrated command

Remaining commands will follow in subsequent PRs (#117#124).

blsmth added 4 commits March 16, 2026 11:08
Add charmbracelet/huh alongside existing survey for incremental migration.
Set up testscript-based CLI integration tests with version and help scripts.
Add YesNoOptions, YesNoToBool, and PrintQuestionHeader helpers to ui package.
Replace survey.Select with huh.Select[int] for the task picker in
scheduled-tasks delete. Uses typed options to store the index directly
instead of survey's OptionAnswer pattern.
Add ui/uitest package with helpers for driving huh forms in tests via
charmbracelet/x/exp/teatest: RunForm, SelectNth, SelectFirst,
TypeAndSubmit, WaitDone.

Extract ScheduledTaskDeleteForm from the Cobra handler so the form
can be tested independently with simulated keypresses. Tests verify
selecting first, second, and last options all bind the correct index.
Includes .tape script for reproducible recording with charmbracelet/vhs.
@blsmth blsmth changed the title Migrate interactive prompts from survey to huh (incremental) Migrate scheduled-tasks delete from survey to huh Mar 20, 2026
@blsmth blsmth self-assigned this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant